import request from '@/utils/request'
/** get请求校验拼接参数是否为空 */
import { praseStrEmpty } from '@/utils/ruoyi'

// 检查是否存在表
export function checkTableExist(data) {
  return request({
    url: '/filOpe/checkTableExist',
    method: 'post',
    data: data
  })
}

// 创建表结构
export function createTable(id) {
  return request({
    url: '/filOpe/createtable/' + praseStrEmpty(id),
    method: 'get'
  })
}

// 数据长度检查
export function checkDataLength(id) {
  return request({
    url: '/filOpe/checkDataLength/' + praseStrEmpty(id),
    method: 'get'
  })
}

// 数据入库
export function dataSave(id) {
  return request({
    url: '/filOpe/fileToDb/' + praseStrEmpty(id),
    method: 'post'
  })
}

// 查询column详细
export function getSdocColumn(id) {
  return request({
    url: '/column/' + praseStrEmpty(id),
    method: 'get'
  })
}

// 删除column
export function delSdocColumn(ids) {
  let data = {
    idList: ids
  }
  return request({
    url: '/column/delete',
    method: 'delete',
    params: data
  })
}

// 修改column
export function updateSdocColumn(data) {
  return request({
    url: '/column/update',
    method: 'put',
    data: data
  })
}

// 查询sdocColumn列表
export function getColumnListByDocId(id) {
  return request({
    url: '/column/list/' + praseStrEmpty(id),
    method: 'get'
  })
}

// 查询sdoc列表
export function listSdoc(query) {
  return request({
    url: '/sdoc/list',
    method: 'get',
    params: query
  })
}

//获取文件头
export function getFileHead(filename) {
  return request({
    url: '/filOpe/getfilehead',
    method: 'post',
    data: filename
  })
}

//提交字段
export function submitField(data) {
  return request({
    url: '/filOpe/fileToDb',
    method: 'post',
    data: data
  })
}

//合并文件
export function mergeFile(data) {
  return request({
    url: '/uploader/mergeFile',
    method: 'post',
    data: JSON.stringify(data)
  })
}

export function selectFileList(query) {
  return request({
    url: '/uploader/selectFileList',
    method: 'get',
    params: query
  })
}

export function deleteFile(data) {
  return request({
    url: '/uploader/deleteFile',
    method: 'post',
    data: JSON.stringify(data)
  })
}

export function downloadFile(query) {
  return request({
    url: '/uploader/download',
    method: 'get',
    params: query
  })
}
